package com.example.tarea2;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class spinner extends Activity {

	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.spinner);
		
		final ImageView imagen =(ImageView)findViewById(R.id.imageView1);
		
		final Spinner spinner_logos = (Spinner) findViewById(R.id.spinner1);
		final ArrayAdapter spinner_adapter = ArrayAdapter.createFromResource( this, R.array.logos , android.R.layout.simple_spinner_item);
		spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner_logos.setAdapter(spinner_adapter);
		
		spinner_logos.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
			public void onItemSelected(AdapterView<?> parent, View v, int posicion, long id){
			
				switch (spinner_logos.getSelectedItemPosition()){ 
					case 0:
						imagen.setImageResource(R.drawable.w);
						break;
					case 1:
						imagen.setImageResource(R.drawable.a);
						break;
					case 2:
						imagen.setImageResource(R.drawable.android);
						break;
					case 3:
						imagen.setImageResource(R.drawable.mix);
						break;
				
					
				}
			}

			public void onNothingSelected(AdapterView<?> parent) {
				imagen.setImageResource(R.drawable.ic_launcher);
			}
			
		});
		
	}
	
	
}
